package com.cskaoyan.service;

import com.cskaoyan.bean.Component1;
import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.UserMapper;
import com.cskaoyan.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{
    
    UserMapper userMapper;//如果没有处理，这个值为null

    @Autowired
    Component1 component1;

    public String queryNameById(Integer id){
        //sqlSession = MyBatisUtil.getSqlSession();
        //UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        //userMapper = sqlSession.getMapper();
        component1.method1();
        String s = userMapper.selectNameById(id);
        //sqlSession.commit();
        //sqlSession.close();
        return s;
    }

        //sqlSession = MyBatisUtil.getSqlSession();
        //UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
    public int insertUser(User user){
        int i = userMapper.insertUser(user);
        //sqlSession.commit();
        //sqlSession.close();
        return i;
    }
}
